package com.sltx.controller;

import com.sltx.controller.base.BaseController;
import com.sltx.service.QyqjService;
import com.sltx.util.PageData;
import com.sltx.util.TextUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping(value = "/qyqj")
public class QyqjController extends BaseController {

    private static final long serialVersionUID = 8900023230688749794L;


    @Autowired
    private QyqjService qyqjService;

    /**
     * 全景查询
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/getByKeyword", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public List<Object> getByKeyword(HttpServletRequest request) throws Exception {
        List<Object> result ;
        PageData pd = this.getPageData();
        String key = pd.get("org_name").toString();

        BigDecimal begin = BigDecimal.valueOf(System.currentTimeMillis());//获取系统当前毫秒值

        result = qyqjService.getByKeyword(pd, key);

        BigDecimal time = BigDecimal.valueOf(System.currentTimeMillis()).subtract(begin).divide(BigDecimal.valueOf(1000));
        String usedTime = TextUtils.format("{0,number,#.###}", time);
        result.add(usedTime);
        return result;

    }

    /**
     * 企业基本信息
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/getEntList", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object getEntList(HttpServletRequest request) {
        PageData pd = this.getPageData();
        Map<String, Object> result = new HashMap<String, Object>();
        //法人基本信息
        result.put("EntList", qyqjService.getEntList(pd));
        //股东及出资信息
        result.put("Shareholder", qyqjService.getShareholder(pd));
        //企业董高监信息
        result.put("Director", qyqjService.getDirector(pd));
        return result;
    }

    /**
     * 储备项目明细
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/getReservePrj", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object getReservePrj(HttpServletRequest request) {
        PageData pd = this.getPageData();
        //List<Map> result = new ArrayList();
        //result = qyqjService.getReservePrj(pd);
        Map<String, Object> result = new HashMap<>();
        result.put("ReservePrj", qyqjService.getReservePrj(pd));
        return result;
    }

    /**
     * 企业纳税信息
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/getEntPayTax", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object getEntPayTax(HttpServletRequest request) {
        PageData pd = this.getPageData();
        Map<String, Object> result = new HashMap<String, Object>();

        //企业纳税信息
        result.put("EntPayTax", qyqjService.getEntPayTax(pd));
        //企业税务信息
        result.put("Taxation", qyqjService.getTaxation(pd));

        return result;
    }

    /**
     * 社保缴纳
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/getSocialSec", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object getSocialSec(HttpServletRequest request) {
        PageData pd = this.getPageData();
//        List<Map> result = new ArrayList();
//        result = qyqjService.getSocialSec(pd);
        Map<String, Object> result = new HashMap<>();
        result.put("SocialSec", qyqjService.getSocialSec(pd));
        return result;
    }

    /**
     * 工商迁入迁出记录
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/getIcChange", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object getIcChange(HttpServletRequest request) {
        PageData pd = this.getPageData();
        Map<String, Object> result = new HashMap<String, Object>();

        //税务迁入记录
        result.put("TaxMoveImp", qyqjService.getTaxMoveImp(pd));
        //税务迁出记录
        result.put("TaxMoveExp", qyqjService.getTaxMoveExp(pd));

        return result;
    }

    /**
     * 政策兑现
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/getPolicyToCash", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object getPolicyToCash(HttpServletRequest request) {
        PageData pd = this.getPageData();
        Map<String, Object> result = new HashMap<String, Object>();

        //政策兑现
        result.put("PolicyToCash", qyqjService.getPolicyToCash(pd));
        //人才引进落户
        result.put("TalentIntroduce", qyqjService.getTalentIntroduce(pd));
        //工作居住证
        result.put("WorkResidencePermit", qyqjService.getWorkResidencePermit(pd));
        //重点企业员工子女入园入学
        result.put("KeynetChild", qyqjService.getKeynetChild(pd));
        //公租房
        result.put("PubHouse", qyqjService.getPubHouse(pd));
        //户口指标分配
        result.put("CensusRegister", qyqjService.getCensusRegister(pd));
        //非京籍应届生落户
        result.put("Nopeking", qyqjService.getNopeking(pd));
        //房租补贴
        result.put("HouseRent", qyqjService.getHouseRent(pd));
        //留学生引进落户
        result.put("OverseaStdu", qyqjService.getOverseaStdu(pd));
        //景贤人才
        result.put("getExcellent", qyqjService.getExcellent(pd));

        return result;
    }

    /**
     * 行政处罚
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/getEntAdmin", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object getEntAdmin(HttpServletRequest request) {
        PageData pd = this.getPageData();
//        List<Map> result = new ArrayList();
//        result = qyqjService.getEntAdmin(pd);
        Map<String, Object> result = new HashMap<>();
        result.put("EntAdmin", qyqjService.getEntAdmin(pd));
        return result;
    }

    /**
     * 疫苗接种
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/getVaccination", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object getVaccination(HttpServletRequest request) {
        PageData pd = this.getPageData();
        //List<Map> result = new ArrayList();
        //result = qyqjService.getVaccination(pd);
        Map<String, Object> result = new HashMap<>();
        result.put("Vaccination", qyqjService.getVaccination(pd));
        return result;
    }


    /**
     * 对外投资
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/getExternal", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object getExternal(HttpServletRequest request) {
        PageData pd = this.getPageData();
        Map<String, Object> result = new HashMap<String, Object>();

        //企业对外投资
        result.put("External", qyqjService.getExternal(pd));
        //分支机构
        result.put("Branch", qyqjService.getBranch(pd));

        return result;
    }

    /**
     * 企业年报
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/getAnnals", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object getAnnals(HttpServletRequest request) {
        PageData pd = this.getPageData();
        Map<String, Object> result = new HashMap<String, Object>();

        //企业年报基本信息
        result.put("Annals", qyqjService.getAnnals(pd));
        //年报股东及出资信息
        result.put("ShareholderYear", qyqjService.getShareholderYear(pd));
        //年报对外投资信息
        result.put("ExternalYear", qyqjService.getExternalYear(pd));
        //年报企业财务状况
        result.put("Finance", qyqjService.getFinance(pd));
        //年报社保信息
        result.put("Security", qyqjService.getSecurity(pd));
        //年报对外担保信息
        result.put("Guarantee", qyqjService.getGuarantee(pd));
        //年报股权变更信息
        result.put("getEquity", qyqjService.getEquity(pd));

        return result;
    }

    /**
     * 企业资质
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/getAptitudes", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object getAptitudes(HttpServletRequest request) {
        PageData pd = this.getPageData();
//        List<Map> result = new ArrayList();
//        result = qyqjService.getAptitudes(pd);
        Map<String, Object> result = new HashMap<>();
        result.put("Aptitudes", qyqjService.getAptitudes(pd));
        return result;
    }

    /**
     * 知识产权
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/getIntellectual", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object getIntellectual(HttpServletRequest request) {
        PageData pd = this.getPageData();
        Map<String, Object> result = new HashMap<String, Object>();

        //专利申请
        result.put("Patent", qyqjService.getPatent(pd));
        //软件著作权
        result.put("Software", qyqjService.getSoftware(pd));
        //作品著作权
        result.put("Works", qyqjService.getWorks(pd));
        //商标注册
        result.put("Trademark", qyqjService.getTrademark(pd));

        return result;
    }

    /**
     * 违法警示
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/getInfringe", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object getInfringe(HttpServletRequest request) {
        PageData pd = this.getPageData();
        Map<String, Object> result = new HashMap<String, Object>();

        //裁判文书
        result.put("Referee", qyqjService.getReferee(pd));
        //法院执行
        result.put("Court", qyqjService.getCourt(pd));

        return result;
    }

    /**
     * 交易项目
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/getDeal", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object getDeal(HttpServletRequest request) {
        PageData pd = this.getPageData();
//        List<Map> result = new ArrayList();
//        result = qyqjService.getDeal(pd);
        Map<String, Object> result = new HashMap<>();
        result.put("getDeal", qyqjService.getDeal(pd));
        return result;
    }

    /**
     * 工商变更
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/getIndustrial", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object getIndustrial(HttpServletRequest request) {
        PageData pd = this.getPageData();
        Map<String, Object> result = new HashMap<>();
        result.put("Industrial", qyqjService.getIndustrial(pd));
        return result;
    }


    /**
     * 企业分析
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/getQyfx", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object getQyfx(HttpServletRequest request) {
        PageData pd = this.getPageData();
        Map<String, Object> result = new HashMap<String, Object>();
//        List<Object> result1 = new  ArrayList<>();
//        result1.add(qyqjService.getRadarMap(pd));
        result.put("LeiDaTu", qyqjService.getLeiDaTu(pd));
        //雷达图信息
        result.put("RadarMap", qyqjService.getRadarMap(pd));

        //潜力企业
        result.put("Qlqy", qyqjService.getQlqy(pd));
        //创新企业
        result.put("Cxqy", qyqjService.getCxqy(pd));

        return result;

    }

    @RequestMapping(value = "/getQyfxx", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object getQyfxx(HttpServletRequest request) {
        PageData pd = this.getPageData();
        List<Object> result = new ArrayList<>();
        // 雷达图信息
        List<Object> radarMap = qyqjService.getRadarMap(pd);

        result.add(radarMap);
        return result;
    }




    /**
     * 预警信息工商变更
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/getYjGsbg", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object getGsbg(HttpServletRequest request) {
        PageData pd = this.getPageData();
        Map<String, Object> result = new HashMap<String, Object>();
        result.put("Gsbg", qyqjService.getGsbg(pd));
        return result;
    }



}

